//基础设施
var vm = new Vue({
    el: '#app',
    data: function() {
        return {
            path: '',//补充图片路径
            eventId: GetQueryString('eventId') || 0,//获取eventId
            contentData: []
        }
    },
    mounted: function() {
        var that = this;
        that.getContent(); //获取详情数据
        mui.init({});
        mui.ready(function() {
            //点击回复标记已读
            $('#listBox').on('tap', '.eventList', function(e) {
                var id = $(this).data('id');
                var index = $(this).data('index');
                that.contentData[index].read=true;
                that.setRead(id);
            })
        })
    },
    methods: {
        //获取详情数据
        getContent: function() {
            var that = this;
            loading.show();
            $.getJSON('/getDetailByEventId', {
                "eventId": that.eventId
            }, function(res) {
                that.contentData = res
                loading.hide();
            })
        },
        //标记已读
        setRead: function(id) {
            var that = this;
            $.post('/addEventMessage', {
                "revertId": id
            }, function(res) {
                console.log(res);
            })
        }
    },
    filters: {
        formatDate: function(nS) {
            return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
        },
        formatUser: function(names) {
            return names.split('@')[1] || '';
        }

    }
})
